/**
 * 
 */
package com.org.javabody.RandomApi.RadomWife;

import java.util.Random;

/**

 * @author admin

 *

 */

class WifeSelect{
	public void myWife(){

		System.out.println("今晚跟谁");
	}

}


class Goto_xue extends WifeSelect{
	public void myWife() {
		System.out.println("跟阿雪一起");
	}
}


class Goto_jing extends WifeSelect{
	public void myWife() {

		System.out.println("跟小静一起");
	}
}

class Goto_yue extends WifeSelect{
	public void myWife() {
		System.out.println("跟小月一起");
	}
}


public class RandomWife implements Runnable{//这个覆盖全程，不要用这个

	private String wife = "";
	private int say_times = 0;  
	public String getWife() {
		return wife;
	}

	public void setWife(String wife) {
		this.wife = wife;
	}


	public void getGotoBed(WifeSelect r) {
		Random ran = new Random();
		Integer a = ran.nextInt(3);
		switch(a) {
		case 0:
			r = new Goto_xue();
			//r.goto_xue();
			break;//不加break跳出会继续加人
		case 1:
			//r.goto_jing();
			r = new Goto_jing();
			break;
		case 2:
			//r.goto_yue();
			r = new Goto_yue();
			break;
		}
		r.myWife();
	}


	@Override
	public void run() {
		// TODO Auto-generated method stub


		for(int i=0; i < 10; i++){
			if(i<7){
				if(say_times <= 5) {
					this.setWife(i+"我今晚要跟谁"); 
					System.out.println(this.getWife()+""+(say_times++));
				}

			} else {
				this.getGotoBed(new WifeSelect());
			}
		}
	}


	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		//new RandomWife().run();

		RandomWife r =new RandomWife();
		Thread thread = new Thread(r);
		thread.start();

		Thread thread2 = new Thread(r);
		thread2.start();

		Thread thread3 = new Thread(r);
		thread3.start();
	}


}
